import 'package:app/pages/timesheet_module/timesheet_detail_module/timesheet_detail_model.dart';
import 'package:app/services/address.dart';
import 'package:app/services/dio_manager.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:get/get.dart';

class TimeSheetDetailController extends GetxController{


  TimeSheetDetailModel? model;


  requestData()async{

    var json = await DioManager().kkRequest('${Address.timeSheetDetail}/${Get.arguments}',method: 'get');

    TimeSheetDetailModel _model = TimeSheetDetailModel.fromJson(json);

    model = _model;

    update();
  }
  
  /// 删除工时单
  requestDataWithUnlink()async{
    var params = {
      'account_analytic_line_id':'${model?.data?.id}',
    };
    var json = await DioManager().kkRequest(Address.unlinkTimeSheet,bodyParams: params);
    if(json['errmsg']=='ok'){

      Get.back(result: 'refresh');
    }
    BotToast.showText(text: json['message']);
  }


  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();

    requestData();

  }
}